libxenlight: two small fixes
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 2 Dec 2009 08:44:40 +0000 (08:44 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 2 Dec 2009 08:44:40 +0000 (08:44 +0000)
- set the domid of the guest and not the one of the stubdom in the
libxl_device_model_starting returned to the user;

- check that the length of the two strings matches in
libxl_name_to_domid, otherwise we can get a match for two different
domains that have the same initial part of the name.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_utils.c

index 10f4d8a4a338d04c667301dc78c61d5655a86fa6..858c17052ec1bc0a872e9282f19e78162e8202b1 100644 (file)
@@ -842,7 +842,7 @@ retry_transaction:
 
     if (starting_r) {
         *starting_r = libxl_calloc(ctx, sizeof(libxl_device_model_starting), 1);
-        (*starting_r)->domid = domid;
+        (*starting_r)->domid = info->domid;
         (*starting_r)->dom_path = libxl_xs_get_dompath(ctx, info->domid);
         (*starting_r)->for_spawn = NULL;
     }
index 6c4b04fd0f8b4538b1f2e8278a0bef204728bc7c..4a8f44f814671bcbf2b536553bcb7f5e60012f9e 100644 (file)
@@ -68,7 +68,7 @@ int libxl_name_to_domid(struct libxl_ctx *ctx, char *name, uint32_t *domid)
     for (i = 0; i < num; i++) {
         snprintf(path, sizeof(path), "/local/domain/%s/name", l[i]);
         domname = xs_read(ctx->xsh, XBT_NULL, path, &len);
-        if (domname != NULL && !strncmp(domname, name, len)) {
+        if (domname != NULL && len == strlen(name) && !strncmp(domname, name, len)) {
             int domid_i = atoi(l[i]);
             for (j = 0; j < nb_domains; j++) {
                 if (dominfo[j].domid == domid_i) {